<template>
    <div class="page-login">
        <div class="login-box">
            <div class="login-title">后台管理系统</div>
            <el-form
                :model="formData"
                :rules="rules"
                label-width="0px"
                ref="login-form"
                class="login-form"
            >
                <el-form-item prop="username">
                    <el-input v-model="formData.username" placeholder="账号">
                        <template #prefix>
                            <i class="el-icon-user"></i>
                        </template>
                    </el-input>
                </el-form-item>
                <el-form-item prop="password">
                    <el-input type="password" placeholder="密码" v-model="formData.password">
                        <template #prefix>
                            <i class="el-icon-lock"></i>
                        </template>
                    </el-input>
                </el-form-item>
                <div class="login-btn">
                    <el-button type="primary" @click="submitForm">登录</el-button>
                </div>
                <p class="login-tips">Tips : [账号: admin, 密码: 123456]</p>
            </el-form>
        </div>
    </div>
</template>

<script>
    export default {
        name: 'page-login',
        data: function () {
            return {
                formData: {
                    username: 'admin',
                    password: '123456'
                },
                rules: {
                    username: [{ required: true, message: '请输入用户名', trigger: 'blur' }],
                    password: [{ required: true, message: '请输入密码', trigger: 'blur' }]
                }
            }
        },
        methods: {
            submitForm () {
                this.$refs['login-form'].validate(valid => {
                    if (!valid) { return false }
                    this.$router.push('/')
                })
            }
        }
    }
</script>

<style lang="scss">
.page-login {
    position: relative;
    width: 100%;
    height: 100%;
    background: url(./login-bg.jpg) center center no-repeat;
    background-size: 100% 100%;
    overflow: hidden;

    .login-box {
        position: absolute;
        left: 50%;
        top: 45%;
        width: 380px;
        transform: translate(-50%, -50%);
        border-radius: 5px;
        box-shadow: inset 0 0 50px 0 rgba(74, 192, 245, 0.5),
            0 0 10px 2px rgba(74, 192, 245, 1);
        overflow: hidden;
        z-index: 10;

        .login-title {
            width: 100%;
            line-height: 60px;
            text-align: center;
            font-size: 25px;
            color: #fff;
            border-bottom: 1px solid #85b4c9;
        }

        .login-form {
            padding: 50px 40px 30px;

            .el-input__inner {
                background-color: transparent;
                color: #fff;
                font-size: 16px;
                border-color: #85b4c9;

                &:hover {
                    border-color: #C0C4CC;
                }

                &:focus {
                    border-color: #fff;
                }
            }

            .login-btn {
                display: flex;

                button {
                    flex: 1;
                }
            }

            .login-tips {
                margin-top: 10px;
                color: #0040ff;
            }
        }
    }
}
</style>
